Who's Hosting This Party?

This script displays information about the current document.



(If the results are undefined then your browser version doesn't support this feature.)

Discussion

Sometimes it's interesting to know what the current document name is, as well as from where it was loaded. (Perhaps it's a way to see if someone is "borrowing" your scripts!)

When the hostname property of a document is empty, the document was loaded from the local computer (as opposed to coming from an HTTP server somewhere). Armed with this knowledge, you can add debugging code to your scripts which the end-user will never ordinarily see, but which will assist you in developing a bug-free script on your home computer before posting it for the world to see:

	<SCRIPT LANGUAGE="JavaScript">

	var inDebug = document.location.hostname=="";

	function countDelimiters(inString,inDelim)
	{
	    var ret = 0;
	    if(inDebug)
		    alert('Incoming string is ['+inString+']\nSearching for ['+inDelim+']');
	    for(var i = 0; i < inString.length; i++)
	        if(inString.charAt(i) == inDelim)
	            ret++;
	    return ret;
	}

	</SCRIPT>




Copyright ©1998 by Charles River Media, All Rights Reserved